package com.example.controller;

import com.example.pojo.PubChannel;
import com.example.service.IPubChannelService;
import com.example.vo.ResultVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 岗位发布渠道信息表 前端控制器
 * </p>
 *
 * @author wsl
 * @since 2022-04-18
 */
@RestController
@RequestMapping("/pubChannel")
@Api(tags = "岗位发布渠道信息表",value = "")
@CrossOrigin(allowCredentials = "true")
public class PubChannelController {

    @Autowired
    private IPubChannelService ipcs;

    @GetMapping
    @ApiOperation("查询所有渠道")
    public List<PubChannel> selChannel(){
        return ipcs.list();
    }

    @PostMapping("/inspc")
    @ApiOperation("新增岗位发布渠道")
    public ResultVo insPuC(@RequestBody PubChannel pc){
        pc.setCreateTime(LocalDateTime.now());
        if (ipcs.save(pc)){
           return ResultVo.ok();
        }
       return ResultVo.error("新增渠道异常");
    }
}
